﻿using HZU.ZP.Data.Impl;
using HZU.ZP.Data.Interfaces;
using HZU.ZP.Domain.IService;
using HZU.ZP.Domain.Model;
using HZU.ZP.Domain.ServiceImpl.Mappers;
using System;
using System.Collections.Generic;
using System.Text;

namespace HZU.ZP.Domain.ServiceImpl.PCSvc
{
    public class PositionService:IPositionService
    {
        private PositionMapper _mapper = new PositionMapper();
        private IPositionDao _sqlData;
        public PositionService(IPositionDao sqlData)
        {
            _sqlData = sqlData;
        }

        public bool Add(Position position)
        {
            var positionDao = _mapper.MapToDao(position);
            _sqlData.Add(positionDao);
            return true;
        }

        public bool Delete(int id)
        {
            _sqlData.Delete(id);
            return true;
        }

        public Position GetById(int id)
        {
            return _mapper.MapToDomain(_sqlData.GetById(id));
        }

        public int GetPositionCount(string sql)
        {
            return _sqlData.GetPositionCount(sql);
        }

        public IList<Position> GetPositionList(int companyId, int status)
        {
            return _mapper.MapToDomainList(_sqlData.GetPositionList(companyId, status));
        }

        public IList<Position> GetPositionList(string sql)
        {
            return _mapper.MapToDomainList(_sqlData.GetPositionList(sql));
        }

        public bool Update(Position position)
        {
            var positionDao = _mapper.MapToDao(position);
            _sqlData.Update(positionDao);
            return true;
        }
    }
}
